package com.bjpowernode.boss.convert;

import com.bjpowernode.boss.domain.UserPayConfig;
import com.bjpowernode.boss.enums.buz.PublicStatus;
import com.bjpowernode.boss.mvc.model.query.UserPayConfigQuery;
import com.bjpowernode.boss.mvc.model.vo.UserPayConfigVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;

import javax.xml.transform.Source;
import java.util.List;

/**
 * 商户配置 转换接口
 */
@Mapper(componentModel = "spring")
public interface UserPayConfigConvert {

    // list<userpayCOnfig> --->  List<userpayconfigVo>
    List<UserPayConfigVo> toConvertupcvList(List<UserPayConfig> userPayConfigList);

    // userpayconfig --->  userpayconfigvo
    @Mappings({
            @Mapping(source = "payProductCode" , target = "productCode"),
            @Mapping(source = "payProductName" , target = "productName"),
            @Mapping(source = "editTime" , target = "editTime" , dateFormat = "yyyy-MM-dd HH:mm:ss"),
            @Mapping(source = "autoSett", target = "autoSett" , qualifiedByName = "handleAutoSettConvert"),
    })
    UserPayConfigVo toConvertyupcv(UserPayConfig userPayConfig);

    @Named("handleAutoSettConvert")
    default String handleAutoSettConvert(String autoSett) {
        String newAutoSett = PublicStatus.YES.getMsg();
        if (!PublicStatus.YES.name().equals(autoSett)) {
            newAutoSett = PublicStatus.NO.getMsg();
        }
        return newAutoSett;
    }


}
